package pl.p10;

import org.antlr.runtime.Token;
import org.antlr.runtime.tree.CommonTree;

public class MyTree extends CommonTree {
  private int line   = 0;
  private int column = 0;

  public MyTree() {
    super();
  }//Constructor

  public MyTree(Token t) {
    super(t);
    if (t != null) {
      line = t.getLine();
      column = t.getCharPositionInLine() + 1;
    }//if
  }//Constructor

  public MyTree(CommonTree ct) {
    super(ct);
    if (ct instanceof MyTree) {
      line = ((MyTree) ct).getLine();
      column = ((MyTree) ct).getColumn();
    }//if
  }//Constructor

  public int getLine() {
    return line;
  }//getLine

  public int getColumn() {
    return column;
  }//getColumn

  public void setLine(int line) {
    this.line = line;
  }//setLine

  public void setColumn(int column) {
    this.column = column;
  }//setColumn

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("");
    String strCommonTree = super.toString();
    sb.append(strCommonTree);
    sb.append(" (");
    sb.append(line);
    sb.append(":");
    sb.append(column);
    sb.append(")");
    return sb.toString();
  }//toString

}//MyTree
